package com.ct.gd.passport.view;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.ct.gd.passport.R;
import com.ct.gd.passport.common.BaseActivity;
import com.ct.gd.passport.common.CTApp;
import com.ct.gd.passport.common.constants.Config;
import com.ct.gd.passport.common.constants.UmengVar;
import com.ct.gd.passport.view.widget.CustomHeaderFragment;
import com.umeng.analytics.MobclickAgent;

public class UserProtocolActivity extends BaseActivity implements
		OnClickListener {

	private CustomHeaderFragment mFgHeader;

	Button mAcceptBtn;
//	Button mRejectBtn;

	@Override
	protected void onBaseCreate(Bundle savedInstanceState) {
		setContentView(R.layout.user_policy);
	}

	@Override
	protected void initViews() {

		mFgHeader = (CustomHeaderFragment) getSupportFragmentManager()
				.findFragmentById(R.id.header);
		mFgHeader.setLeftView(null);
		mFgHeader.setCenterText(getString(R.string.user_policy_title));

//		mRejectBtn = (Button) findViewById(R.id.btn_user_policy_reject);
		mAcceptBtn = (Button) findViewById(R.id.btn_user_policy_accept);

//		mRejectBtn.setOnClickListener(this);
		mAcceptBtn.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
//		if (v.getId() == mRejectBtn.getId()) {
//			onReject();
//		}
		if (v.getId() == mAcceptBtn.getId()) {
			onAccept();
		}
	}

	private void onReject() {
		UserProtocolActivity.this.setResult(RESULT_OK);
		this.finish();
	}

	private void onAccept() {
		try {
			MobclickAgent.onEvent(this, UmengVar.AGREE);
			CTApp.getInstance().sendSmsForUserProtocol(Config.SEND_AGREE_CONTENT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.finish();
	}

	
}
